<template>
  <el-dialog :title="title" v-model="visible" :close-on-click-modal="false" draggable>
    <div v-loading="state.loading">
      <el-table height="calc(100vh - 350px)" :data="state.dataList" border
                :cell-style="tableStyle.cellStyle"
                :header-cell-style="tableStyle.headerCellStyle" highlight-current-row
                @sort-change="sortChangeHandle">
        <el-table-column type="index" label="#" width="60"/>
        <el-table-column prop="doctorName" label="医生姓名" show-overflow-tooltip/>
        <el-table-column prop="doctorCode" label="医生工号" show-overflow-tooltip/>
        <el-table-column prop="icCard" label="身份证号" width="200" show-overflow-tooltip/>
        <el-table-column prop="dept" label="就诊科室" show-overflow-tooltip/>
        <el-table-column prop="visitTime" label="就诊时间" width="160" show-overflow-tooltip/>
        <el-table-column prop="visitEndTime" label="就诊结束时间" width="160" show-overflow-tooltip/>
      </el-table>
      <pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle"
                  v-bind="state.pagination"/>
    </div>
  </el-dialog>
</template>
<script setup lang="ts" name="seeDoctorView">
import {BasicTableProps, useTable} from "/@/hooks/table";
import {
  getCustomerOutpatients
} from "/@/api/blood/bloodFamilyDoctor";

const visible = ref(false);
const title = ref('患者就诊记录');

const state: BasicTableProps = reactive<BasicTableProps>({
  queryForm: {},
})

const {
  getDataList,
  currentChangeHandle,
  sizeChangeHandle,
  sortChangeHandle,
  tableStyle
} = useTable(state);

const openDialogSee = (doctorId: any, icCard: any, startTime: any, endTime: any) => {
  visible.value = true;
  if (doctorId) {
    state.queryForm.doctorId = doctorId;
  } else {
    delete state.queryForm.doctorId;
  }
  if (startTime) state.queryForm.startTime = startTime;
  if (endTime) state.queryForm.endTime = endTime;
  if (icCard) state.queryForm.icCard = icCard;
  state.pageList = getCustomerOutpatients
  getDataList()
};

// 暴露变量
defineExpose({
  openDialogSee,
});
</script>
